package feesmodule.converter;

import feesmodule.domain.Area;
import feesmodule.domain.Jurisdiction;
import java.util.ArrayList;
import java.util.Collection;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="area")
public class AreaConverter
{
    private Area item;
    private JurisdictcionsConverter jurisdictionsItem;

    public AreaConverter(Area area)
    {
        this.item = area;
    }
    public AreaConverter()
    {}
    
    @XmlElement(name="areaname")
    public String getName()
    {
        return item.getName();
    }
    @XmlAttribute
    public int getId()
    {
        return item.getId();
    }
    @XmlElement
    public JurisdictcionsConverter getJurisdictions()
    {
        if(jurisdictionsItem == null)
            jurisdictionsItem =  new JurisdictcionsConverter(item.getJurisdictions());
        return jurisdictionsItem;
    }

    public void setName(String name)
    {
        item.setName(name);
    }

    public void setId(int id)
    {
        item.setId(id);
    }

    public static class JurisdictcionsConverter
    {
        private Collection<JurisdictionConverter> items;
        private Collection <Jurisdiction> jurisdictions;

        public JurisdictcionsConverter(Collection<Jurisdiction> jurisdictions)
        {
            this.jurisdictions = jurisdictions;
        }
        public JurisdictcionsConverter()
        {
        }
        @XmlElement
        public Collection <JurisdictionConverter> getJurisdiction()
        {
            if(items == null)
                items = new ArrayList<JurisdictionConverter>();
            for(Jurisdiction j : jurisdictions)
                items.add(new JurisdictionConverter(j));
            return items;
        }

    }
}
